package com.wyl.search.bean;

import java.util.List;
import java.util.Map;

public class PaginationBean {
	private int sumRecord;
	private int sumPage;
	private int firstPageNo;
	private int lastPageNo;
	private int frontPageNo;
	private int behindPageNo;
	private int currentPageNo;	
	private int pageSize;
	private Map<String,String> requestParam;
	private int[] pageNoList;

	private List dataList;
	
	private String formName;
	private String targetDivName;
	
	public String getFormName() {
		return formName;
	}
	public void setFormName(String formName) {
		this.formName = formName;
	}
	public String getTargetDivName() {
		return targetDivName;
	}
	public void setTargetDivName(String targetDivName) {
		this.targetDivName = targetDivName;
	}
	public int getSumRecord() {
		return sumRecord;
	}
	public void setSumRecord(int sumRecord) {
		this.sumRecord = sumRecord;
	}
	public int getSumPage() {
		return sumPage;
	}
	public void setSumPage(int sumPage) {
		this.sumPage = sumPage;
	}
	
	public int getFrontPageNo() {
		return frontPageNo;
	}
	public void setFrontPageNo(int frontPageNo) {
		this.frontPageNo = frontPageNo;
	}
	public int getBehindPageNo() {
		return behindPageNo;
	}
	public void setBehindPageNo(int behindPageNo) {
		this.behindPageNo = behindPageNo;
	}
	public int getCurrentPageNo() {
		return currentPageNo;
	}
	public void setCurrentPageNo(int currentPageNo) {
		this.currentPageNo = currentPageNo;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	
	public List getDataList() {
		return dataList;
	}
	public void setDataList(List dataList) {
		this.dataList = dataList;
	}
	public int[] getPageNoList() {
		return pageNoList;
	}
	public void setPageNoList(int[] pageNoList) {
		this.pageNoList = pageNoList;
	}
	public int getFirstPageNo() {
		return firstPageNo;
	}
	public void setFirstPageNo(int firstPageNo) {
		this.firstPageNo = firstPageNo;
	}
	public int getLastPageNo() {
		return lastPageNo;
	}
	public void setLastPageNo(int lastPageNo) {
		this.lastPageNo = lastPageNo;
	}

	public Map<String, String> getRequestParam() {
		return requestParam;
	}
	public void setRequestParam(Map<String, String> requestParam) {
		this.requestParam = requestParam;
	}
	public String pagination(){
		if(currentPageNo==firstPageNo && lastPageNo==0)
			return "";
		StringBuffer result=new StringBuffer("<ul class=\"pagination\">");		
		if(currentPageNo==firstPageNo){
			result.append("<li class=\"disabled\"><a href=\"#\">第一页</a></li>");
			result.append("<li class=\"disabled\"><a href=\"#\">上一页</a></li>");
		}else{
			result.append("<li><a href=\"#\" onclick=\"pagination('" + formName + "','" + targetDivName + "',"+ firstPageNo + ")\">第一页</a></li>");
			result.append("<li><a href=\"#\" onclick=\"pagination('" + formName + "','" + targetDivName + "',"+ frontPageNo + ")\">上一页</a></li>");
		}
		
		
		for(int pageNo : pageNoList){
			if(currentPageNo==pageNo)
				result.append("<li class=\"active\"	><a href=\"#\">"+ pageNo+ "</a></li>");
			else
				result.append("<li><a href=\"#\" onclick=\"pagination('" + formName + "','" + targetDivName + "',"+ pageNo + ")\">"+ pageNo+ "</a></li>");
		}	
		
		if(currentPageNo==lastPageNo){
			result.append("<li class=\"disabled\"><a href=\"#\">下一页</a></li>");
			result.append("<li class=\"disabled\"><a href=\"#\">最后一页</a></li>");
		}else{
			result.append("<li><a href=\"#\" onclick=\"pagination('" + formName + "','" + targetDivName + "',"+ behindPageNo + ")\">下一页</a></li>");
			result.append("<li><a href=\"#\" onclick=\"pagination('" + formName + "','" + targetDivName + "',"+ lastPageNo + ")\">最后一页</a></li>");
		}
		
		result.append("</ul>");
		return result.toString();
	}
	
}
